const tree = require('./binTree.js')

function hasPathSum(root, target) {
    if (!root) return false
    let flag = false
    const stack = [root]
    let sum = 0
    while (stack.length) {
        const n = stack.pop()
        if (!n.left && !n.right) {

        }
        console.log(n.val)
        if (n.right) {
            stack.push(n.right)
        }
        if (n.left) {
            stack.push(n.left)
        }
    }
    return flag
}

console.log(hasPathSum(tree, 4))